<?php
/**
 * Created by PhpStorm.
 * User: PHP
 * Date: 2021/6/18
 * Time: 10:36
 */

namespace App\Dao\notice;
use App\Dao\BaseDao;
use App\Exceptions\ApiException as HOException;
use Illuminate\Support\Facades\DB;
use App\Models\notice\NoticeRecordModel;
class NoticeRecordDao extends BaseDao
{

    public function setModel(){
        return NoticeRecordModel::class;
    }

    public function add_record($all){

        $all['type'] = 2;

        return $this->create($all);

    }


    //一看公告人数
    public function get_list($notice_id){

        $data = $this->getList(['notice_id'=>$notice_id],['id','user_id','notice_id','type','platform_id','created_at']);

        foreach ($data as $k=>&$v){
            $v['account_name'] = DB::table('system_admin')->where('id',$v['user_id'])->value('account');
            if (!empty($v['platform_id'])){
                $v['un_name'] = DB::table('un_store')->where('id',$v['platform_id'])->value('un_name');
            }else{
                $v['un_name'] = '';
            }
            if ($v['type'] == 1){
                $v['type'] = '电子合同';
            }else{
                $v['type'] = 'SAAS平台';
            }

        }

        return $data;

    }









}
